obj = {
	add:function () {
		var awin = $('#addMoldWin');
		awin.panel({title: "新增类型"}).dialog("open");
	},
	edit:function(){
		  var node = $('#equipMold_data').datagrid('getSelected');
		  if(node!=null){
		  	  var ewin = $('#editMoldWin');
			  $.post(basePath+"/equMold/load.json",{'id':node.id},function(res){
			  		ewin.form('load', {
			  			equType : res.data.equType,
			  			equFormat : res.data.equFormat,
			  			ratedPower : res.data.ratedPower,
			  			supplier : res.data.supplier,
			  			life : res.data.life,
			  			remark : res.data.remark,
						id:res.data.id
					}).dialog('open');
			  });
		  }else{
			  $.messager.alert("提示信息","请选择一条记录!");
		  }
	},
	deletes:function(){
		var node = $('#equipMold_data').datagrid('getSelected');
		if(node!=null){
			 $.post(basePath+"/equMold/delete.json",{'id':node.id},function(res){
				 if(res.success){
						$('#equipMold_data').datagrid('reload');
					}else{
						$.messager.alert("提示信息",res.msg);
					}
			  });
		}else{
			$.messager.alert("提示信息","请选择一条记录!");
		}
	}
	
};
	
$(function(){
	$('#equipMold_data').datagrid({
		url: basePath+"/equMold/findByAll.json",
	    method: 'get',
	    striped : true,
		nowrap : true,
		rownumbers : true,
		fitColumns : true,
		singleSelect:true,
		border:false,
		toolbar:'#tb_sb',
		scrollbarSize:1,
		pageSize: 2,
		 pageList: [2,5,10,20],
//		title:'设备',
		columns:[[
	          {field:'equType',align:'center','title':'设备类型',width:200},
	          {field:'equFormat',align:'center','title':'设备型号',width:200},
	          {field:'ratedPower',align:'center','title':'额定功率',width:100},
	          {field:'supplier',align:'center','title':'生产厂家',width:150},
	          {field:'life',align:'center','title':'使用寿命',width:150},
	          {field:'remark',align:'center','title':'备注',width:150}
        ]],
	    pagination : true,
  		pageList : [5,10],
  		pageNumber : 1,
		pageSize : 10,
  		pagePosition : 'bottom'
	});
	
	
	
	//添加
	$('#addMoldWin').dialog({
		width:400,
		height:300,
		iconCls:'icon-add',
		closed: true,
		modal: true,
		inline:true,
		buttons:[{
			text:'提交',
			iconCls:'icon-add-new',
			handler:function(){
				if($('#addMoldform').form('validate')){
					$.post(basePath+"/equMold/save.json",$("#addMoldform").serialize(),function(data){
						if(data!=null){
							$('#addMoldWin').dialog('close');
							$('#equipMold_data').datagrid('reload');
						}else{
							$.messager.alert({title:'消息提示',msg:'操作失败',timeout:3000});
						}
					});
				}
			}
		},{
			text:'取消',
			iconCls:'icon-redo',
			handler:function(){
				$('#addMoldWin').dialog('close');
			}
		}],
		onClose: function() {
			$('#addMoldform').form('reset');
		}
	});
	
	//编辑
	$('#editMoldWin').dialog({
		title:'编辑',
		width:400,
		height:300,
		iconCls:'icon-edit',
		closed: true,
		modal: true,
		inline:true,
		buttons:[{
			text:'提交',
			iconCls:'icon-add-new',
			handler:function(){
				if($('#editMoldform').form('validate')){
					$.post(basePath+"/equMold/update.json",$("#editMoldform").serialize(),function(data){
						if(data.success){
							$('#editMoldWin').dialog('close');
							$('#equipMold_data').datagrid('reload');
						}else{
							$.messager.alert({title:'消息提示',msg:data.msg,timeout:3000});
						}
					});
					
				}
			}
		},{
			text:'取消',
			iconCls:'icon-redo',
			handler:function(){
				$('#editMoldWin').dialog('close');
			}
		}],
		onClose: function() {
			$('#editMoldform').form('reset');
		}
	});
	
});
